from application.flask import app
from application.utils.responseUtils import successResponse
from ..model.Posting import Posting
from flask import request
from ..utils.db import db
import json


@app.route("/posting/add", methods=["POST"])
def addPosting():
    body: dict = json.loads(request.data.decode())
    posting = Posting(**body)
    gtoken = request.headers.get("x-token-gtoken")
    utoken = request.headers.get("x-token-utoken")
    db.session.add(posting)
    db.session.commit()
    return successResponse()
